local allfail = STATSMAN:GetCurStageStats():AllFailed()
local t = Def.ActorFrame {}

for i=0,1 do
	t[#t+1] = LoadActor("BACK01")..{
		InitCommand=function(self)
			(cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;spin))(self);
			self:zoom(i == 0 and 2 or 1.5);
			self:diffusealpha(i == 0 and 1 or 0.5);
			self:effectmagnitude(0,0,3-i);
		end;
	}
end

t[#t+1] = LoadActor("text1")..{
	InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y+52);
	OnCommand=cmd(diffusealpha,0;sleep,0.2;diffusealpha,1;sleep,6.3;diffusealpha,0);
}

for i=0,1 do
	t[#t+1] = LoadActor("SIDE")..{
		InitCommand=function(self)
			(cmd(y,SCREEN_BOTTOM+8;diffusealpha,0.5;horizalign,left;vertalign,bottom;blend,'BlendMode_Normal'))(self);
			self:x(i == 0 and SCREEN_LEFT or SCREEN_RIGHT);
			self:rotationy(180 * i);  --180 * 1 = 180, 180 * 0 = 0 :D
		end;
		OnCommand=function(self)
			local ji = i == 0 and -1 or 1;
			self:addx(200*ji);
			self:decelerate(0.4);
			self:addx(200*-ji);
			(cmd(sleep,6.3;decelerate,0.4))(self);
			self:addx(200*ji);
		end;
	}
end

t[#t+1] = Def.Quad {
	InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_TOP+45;diffuse,0,0,0,0.5;zoomto,SCREEN_WIDTH,76);
	OnCommand=cmd(addx,-SCREEN_WIDTH;linear,0.4;addx,SCREEN_WIDTH;sleep,6.1;linear,0.4;addx,-SCREEN_WIDTH);
}

t[#t+1] = LoadActor("TITLE")..{
	InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_TOP+45;zoomto,SCREEN_WIDTH,80);
	OnCommand=cmd(addy,-85;decelerate,0.4;addy,85;sleep,6.1;decelerate,0.4;addy,-85);
}

for i=0,1 do
	t[#t+1] = Def.Quad {
		InitCommand=function(self)
			(cmd(x,SCREEN_CENTER_X;zoomto,SCREEN_WIDTH,80;diffuse,0,0,0,1))(self)
			self:y(SCREEN_BOTTOM * i);
			self:vertalign(i == 0 and top or bottom);
		end;
		OnCommand=function(self)
			local ji = i == 0 and -1 or 1;
			self:addx(-SCREEN_WIDTH*ji);
			(cmd(sleep,7;linear,0.2))(self);
			self:addx(SCREEN_WIDTH*ji);
		end;
	}
end

t[#t+1] = LoadActor(allfail and "FAIL1" or "CLEAR1")..{
	InitCommand=cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y);
	OnCommand=cmd(addx,-SCREEN_WIDTH;sleep,7.5;linear,0.3;x,SCREEN_CENTER_X-52;linear,0.5;x,SCREEN_CENTER_X;sleep,1.7;linear,0.3;addx,SCREEN_WIDTH);
}

--[[
por hacer: lograr que se reproduzcan secuencialmente D:
hora de preguntar en los foros de SM.com n_n
***************
fixed. Thanks to shakesoda :D
***************
arreglado. Gracias a refrescoagitado :D
(la traduxión, jeje)
]]

t[#t+1] = Def.Actor {
	OnCommand=function(self)	
		self:sleep(1);
		self:queuecommand("Score")
	end;
	ScoreCommand=function(self)
		SOUND:PlayOnce(THEME:GetPathS("","_scoring"));
		self:sleep(2.5);
		self:queuecommand("Bang")
	end;
	BangCommand=function(self)
		SOUND:PlayOnce(THEME:GetPathS("","9-5"));
	end;
}

return t